package com.ifighter.service.cluster;

import java.sql.SQLException;
import java.util.ArrayList;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class ClusterService {

	private SQLiteDatabase db; 

	public ClusterService(SQLiteDatabase db){
		this.db = db;
	}

	/**
	 * 
	 * @return
	 * @throws SQLException
	 */
	public Cluster[] getTeamByName() throws SQLException{

		StringBuffer sql       = new StringBuffer();
		String[] selectionArgs = {};
		Cursor cursor          = null;
		Cluster[] result       = null;
		ArrayList<Cluster> tmp = null;

		tmp = new ArrayList<Cluster>();

		sql.append("SELECT * FROM ");
		sql.append(Cluster.TABLE);

		cursor = this.db.rawQuery(sql.toString(), selectionArgs);

		while (cursor.moveToNext()){
			tmp.add(new Cluster(cursor));
		}

		result = tmp.toArray(new Cluster[tmp.size()]);

		return result;
	}	
}